package com.smrs.goods.dao;

import java.util.List;

import org.hibernate.Query;

import com.jof.framework.dao.hibernate.BaseDAOHibernateImpl;
import com.smrs.goods.model.GoodsCategoryModel;
import com.smrs.goods.model.GoodsItemModel;

public class GoodsItemDao extends BaseDAOHibernateImpl<GoodsItemModel, Long>{
	public List<GoodsItemModel> findByGoodsCategory(GoodsCategoryModel goodsCategory){
		String queryString = " from GoodsItemModel where 1=1";
		if(goodsCategory.getLevel().longValue()==1){
			queryString = queryString+" and categoryId1="+goodsCategory.getId();
		}else if(goodsCategory.getLevel().longValue()==2){
			queryString = queryString+" and categoryId2="+goodsCategory.getId();
		}else if(goodsCategory.getLevel().longValue()==3){
			queryString = queryString+" and categoryId3="+goodsCategory.getId();
		}else if(goodsCategory.getLevel().longValue()==4){
			queryString = queryString+" and categoryId4="+goodsCategory.getId();
		}
		Query query = this.createHQLQuery(queryString, new Object[]{});
		List<GoodsItemModel> list = query.list();
		return list;
	}
}
